import 'dart:io';
import 'package:camera/camera.dart';
import 'package:get/get.dart';

class ContinuousCameraController extends GetxController {
  late CameraController controller;
  var cameras = <CameraDescription>[];
  var pictures = <File>[];

  Future<void> init() async {
    cameras = await availableCameras();
    controller = CameraController(cameras[0], ResolutionPreset.high);
    await controller.initialize();
    update();
  }

  Future<void> takePictures() async {
    XFile pictureFile = await controller.takePicture();
    File file = File(pictureFile.path);
    pictures.add(file);
    update();
  }

  @override
  void onInit() {
    super.onInit();
    init();
  }

  @override
  void onClose() {
    controller.dispose();
    super.onClose();
  }
}
